#include<stdio.h>
#include<stdlib.h>
struct BTNode{
	char data;
	struct BTNode *pLchild;
	struct BTNode *pRchild;
};
struct BTNode *createBTree(void); 
void PreTraverseBTree(struct BTNode *pT);
void InTraverseBTree(struct BTNode *pT);
void PostTraverseBTree(struct BTNode *pT);
int main(){
	struct BTNode *pT=createBTree();
	PreTraverseBTree(pT);
	//InTraverseBTree(pT);
	//PostTraverseBTree(pT);
	return 0;
}
struct BTNode *createBTree(void){
	struct BTNode *pA=(struct BTNode *)malloc(sizeof(struct BTNode));
	struct BTNode *pB=(struct BTNode *)malloc(sizeof(struct BTNode));
	struct BTNode *pC=(struct BTNode *)malloc(sizeof(struct BTNode));
	struct BTNode *pD=(struct BTNode *)malloc(sizeof(struct BTNode));
	struct BTNode *pE=(struct BTNode *)malloc(sizeof(struct BTNode));
	
	pA->data='A';
	pB->data='B';
	pC->data='C';
	pD->data='D';
	pE->data='E';
	
	pA->pLchild=pB;
	pA->pRchild=pC;
	pB->pLchild=pB->pRchild=NULL;
	pC->pLchild=pD;
	pC->pRchild=NULL;
	pD->pLchild=NULL;
	pD->pRchild=pE;
	pE->pLchild=pE->pRchild=NULL;
	return pA;
}
void PreTraverseBTree(struct BTNode *pT){
	if(pT!=NULL){
		printf("%c\n",pT->data);
			if(pT->pLchild!=NULL){
				PreTraverseBTree(pT->pLchild);
			}
			if(pT->pRchild!=NULL){
				PreTraverseBTree(pT->pRchild);
			}
		}
}
void InTraverseBTree(struct BTNode *pT){
	if(pT!=NULL){
			if(pT->pLchild!=NULL){
				PreTraverseBTree(pT->pLchild);
			}
			printf("%c\n",pT->data);
			if(pT->pRchild!=NULL){
				PreTraverseBTree(pT->pRchild);
			}
		}
}
void PostTraverseBTree(struct BTNode *pT){
		if(pT!=NULL){
			if(pT->pLchild!=NULL){
				PreTraverseBTree(pT->pLchild);
			}
			if(pT->pRchild!=NULL){
				PreTraverseBTree(pT->pRchild);
			}
				printf("%c\n",pT->data);
		}
}
